/**
 * FileName:         NoticeServiceImpl.java
 * @Description:     TODO
 * @author:            zl
 * @version            V1.0
 * Createdate:      2019年1月10日     下午4:44:37
 * Copyright:       
 * Company           CY.
 * All rights Reserved, Designed By crane-yuan

 * Modification  History:
 * Date         Author        Version        Discription
 * ---------------------------------------------------------------------------
 * 2019年1月10日     crane-yuan       1.0             1.0

 * Why & What is modified:

 */
package com.Brewing.springboot.service.TpNotice;

import java.text.SimpleDateFormat;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.Brewing.springboot.common.PagedResult;
import com.Brewing.springboot.common.TimeAgoUtils;
import com.Brewing.springboot.entity.TpNotice.TpNotice;
import com.Brewing.springboot.mapper.TpNoticeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Company: </p>
 * @author  庄磊
 * @date	2019年1月10日 下午4:44:37 
 * @version 1.0
 */
@Service
public class NoticeServiceImpl implements NoticeService{
	@Autowired
	private TpNoticeMapper tpNoticemapper;
	/**
	 * <p>Title: getNotice</p>
	 * <p>Description: </p>
	 */ 
	@Override
	public PagedResult getNotice(String userId, Integer page, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page,pageSize);
		List<TpNotice> list = tpNoticemapper.queryByFanNotice(userId);
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		for(TpNotice notices : list) {
			notices.setStrData(simpleDateFormat.format(notices.getCreateData()));
		}
		PageInfo<TpNotice> pageList = new PageInfo<>(list);
		PagedResult pagedResult = new PagedResult();
		pagedResult.setTotal(pageList.getPages());
		pagedResult.setRows(list);
		pagedResult.setPage(page);
		pagedResult.setRecords(pageList.getTotal());
		return pagedResult;
	}

}
